local socket = require "socket"

-- 创建 TCP 服务器套接字
local server = socket.bind("*", 8888)
print("Server started on port 8888")

while true do
    -- 接受新连接
    local client = server:accept()
    print("New client connected")

    -- 接收消息
    local line, err = client:receive()
    if not err then
        print("Received from client:", line)
        -- 发送响应
        client:send("Echo: " .. line .. "\n")
    end

    -- 关闭连接
    client:close()
end
